import request from '@/utils/request.js'
// 获取用户列表
export const getUserDetail = (data) => {
  var newUrl = `/user`
  if (data) {
    newUrl += `?_page=${data.page}&_limit=${data.size}`
  }
  return request({
    method: 'GET',
    url: newUrl
  })
}
// 删除选中的用户
export const delUser = (id) => {
  return request({
    method: 'DELETE',
    url: `/user/${id}`
  })
}

// 获取用户信息
export const getTheUser = (id) => {
  return request({
    method: 'GET',
    url: `/user/${id}`
  })
}

// 获取用户信息
export const addUser = (data) => {
  return request({
    method: 'POST',
    url: `/user`,
    data
  })
}

// 编辑用户信息
export const editUser = (data) => {
  return request({
    method: 'PATCH',
    url: `/user/${data.id}`,
    data
  })
}
// 根据输入的条件查询用户信息
export const getUserInfo = (data) => {
  var newUrl = `/user?`
  if (data.username) {
    newUrl += `username=${data.username}`
  }
  if (data.mobile) {
    newUrl += `&mobile=${data.mobile}`
  }
  return request({
    method: 'GET',
    url: newUrl
  })
}
